package com.example.demo.controller;

import com.example.demo.entity.Cat;
import com.example.demo.service.CatService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Created by Choisaaaa on 2018/6/6.
 */
@RestController
@RequestMapping("/cat")
public class CatController {

    @Resource
    private CatService catService;

    @RequestMapping("/save")
    public void save(){
        Cat cat = new Cat();
        cat.setCatAge(18);
        cat.setCatName("cat");
        catService.save(cat);
    }

    @RequestMapping("/findByCatName")
    public Cat findByCatName(String catName){
        return catService.findByCatName(catName);
    }

    @RequestMapping("/findByCatName2")
    public Cat findByCatName2(String catName){
        return catService.findByCatName2(catName);
    }


    @RequestMapping("/selectByCatName")
    public Cat selectByCatName(String catName){
        return catService.selectByCatName(catName);
    }
}
